Skip to content

feat: [Performance] Allow to pass a selector to the useWindowDimensions hook to avoid unnecessary re-renders#56989

Closed
retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/useWindowDimensions-with-selector
Closed

feat: [Performance] Allow to pass a selector to the useWindowDimensions hook to avoid unnecessary re-renders#56989
retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/useWindowDimensions-with-selector

Conversation

@retyui

@retyui retyui commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

Performance issue was shown on App.js 2026 Conf: https://www.youtube.com/live/4H8iRPN0Q2M?si=pykgDXJcbvi7_OIC&t=8704 by @jmeistrich

// but now with this PR devs can pass a selector 
// to subscribe to `fontScale` changes only 
const fontScale = useWindowDimensions(state => state.fontScale)
Screenshot 2026-05-28 at 18 12 22

Changelog:

[GENERAL] [ADDED] - Allow to pass a selector to useWindowDimensions(state => state.fontScale) to avoid unnecessary re-renders

Test Plan:

I did my best to cover all testcases:

yarn test packages/react-native/Libraries/Utilities/__tests__/useWindowDimensions-test.js

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 28, 2026
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 28, 2026
@Palloxin

Palloxin commented Jun 3, 2026

Copy link
Copy Markdown

Is the performance boost with this pr big? btw now this pr has conflicts

@retyui

retyui commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

btw now this pr has conflicts

ReactNativeApi.d.ts I can't prevent these conflicts

Is the performance boost with this pr big?

this PR is about "avoiding unnecessary re-renders"

@retyui retyui closed this by deleting the head repository Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants